using System.Runtime.InteropServices;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Graphics.PackedVector;

namespace XDL.Framework.Particles
{
    /// <summary>
    /// Custom TracerBullet element.
    /// </summary>
    [StructLayout(LayoutKind.Sequential)]
    public struct LineVertex
    {
        // CPU/GPU information
        public Vector3 Position;
        public Vector2 Texcoord;
        public Vector3 Velocity;
        public Color Random;
        public float Lifetime;

        // map struct items to 'vertex' behaviors
        public static readonly VertexDeclaration VertexDeclaration = new VertexDeclaration
            (
                new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0),
                new VertexElement(24, VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0),
                new VertexElement(36, VertexElementFormat.Vector3, VertexElementUsage.Normal, 0),
                new VertexElement(60, VertexElementFormat.Color, VertexElementUsage.Color, 0),
                new VertexElement(68, VertexElementFormat.Single, VertexElementUsage.TextureCoordinate, 1)
            );

        public const int SizeInBytes =
            3 * sizeof(float) + // position
            2 * sizeof(float) + // texcoord
            3 * sizeof(float) + // direction
            sizeof(float) + // random
            sizeof(float);  // lifetime
    }
}
